<?php

namespace app\admin\validate;

use think\Validate;

class User extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
	    'password' => 'checkPassword',
        'repass'=>'confirm:password'
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [
        'password.min' => "密码不能少于6个字符",
        'repass.confirm' => '两次输入的密码不一致'
    ];

    protected $scene = [
        'edit'  =>  ['password','repass'],
    ];

    protected function checkPassword($value)
    {
        if ($value && strlen($value) < 6){
            return "密码不能少于6个字符";
        }
    }
}
